<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript"
            src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=NQWF06ORnEeed478EimQwhIROHbUAK5B"></script>
    <title>位置定位</title>
    <style>
        html, body, #allmap {
            width: 100%;
            height: 100%;
            padding: 0;
            margin: 0;
            overflow: hidden;
        }

        #result {
            padding: 7px 10px;
            /*position: fixed;*/
            top: 10px;
            left: 20px;
            width: 450px;
            background: #fff;
            box-shadow: 0 2px 6px 0 rgba(27, 142, 236, 0.5);
            border-radius: 7px;
            z-index: 99;
        }

        #result input {
            width: 130px;
            margin-right: 10px;
            height: 25px;
            border: 1px solid rgba(27, 142, 236, 0.5);
            border-radius: 5px;
        }

        #result button {
            border: 1px solid rgba(27, 142, 236, 0.5);
            border-radius: 5px;
            background: rgba(27, 142, 236, 0.5);
            color: #fff
        }
    </style>
</head>
<body>


<!--    <div class="panel-head"><strong class="icon-reorder"> 用户信息:</strong> <a href=""-->
<!--                                                                         style="float:right; display:none;">添加字段</a>-->
<!--    </div>-->

<!--    <tr v-for="UMap in this.list" >-->

<!--        <td v-text="UMap.id">{{list.id}}</td>-->
<!--        <td width="20%"><img :src="UMap.avatar" alt="" width="70" height="50"/></td>-->
<!--        <td v-text="UMap.nickName"></td>-->
<!--        <td v-text="UMap.address"></td>-->

<!--    </tr>-->
<div id="result" style="width:100%;height: 120px;display:flex; background-color:#fff; ">
    <div>
        <img :src="ssss.avatar" style="height: 120px;width: 120px;" />
    </div>
    <div>
        <ul>
            <li>用户ID：<span v-text="ssss.userId"></span></li>
            <li>昵称：<span v-text="ssss.nickName"></span></li>
            <li>性别：男</li>
            <li>城市：<span v-text="ssss.address"></span></li>

        </ul>
    </div>
    <div id='' style="display: none">
        经度: <input id="lng" type="text" v-model="longitude"/>
        纬度: <input id="lat" type="text" v-model="latitude"/>
        <button onclick="theLocation()" id="btn"/>
        查询</button>
    </div>
</div>

<div id='allmap' style="martgin-top:20px;"></div>


<script>
    window.onload = function () {
        document.getElementById("btn").click();

    }
    // 百度地图API功能
    var map = new BMapGL.Map("allmap");
    map.centerAndZoom(new BMapGL.Point(116.347079,40.064813), 15);
    map.enableScrollWheelZoom(true);

    // 用经纬度设置地图中心点
    function theLocation() {
        if (document.getElementById("lng").value != "" && document.getElementById("lat").value != "") {
            map.clearOverlays();
            var new_point = new BMapGL.Point(document.getElementById("lng").value, document.getElementById("lat").value);
            var marker = new BMapGL.Marker(new_point);  // 创建标注
            map.addOverlay(marker);              // 将标注添加到地图中
            map.panTo(new_point);
        }
    }
</script>
</body>
</html>
<script src="./js/vuejs-2.5.16.js"></script>
<script src="./js/axios-0.18.0.js"></script>
<script>
    const app = new Vue({
        el: '#result',
        data: {
                ssss: {},
                longitude: "",
                latitude: "",
                userId: '',
        },
        methods: {
            findById(userId) {
                axios.get("/user/locale?uid=" + this.userId).then(resp => {
                    this.ssss = resp.data;
                    console.log(this.ssss, '>>>');
                    this.longitude = resp.data.longitude;
                    this.latitude = resp.data.latitude;
                })
            }
        },
        created() {
            this.userId = location.search.split("=")[1];
            this.findById(this.userId);
        }
    })
</script>
